﻿#ifndef _SERIAL_FILE_COM_NOBUF_H_
#define _SERIAL_FILE_COM_NOBUF_H_

#include "serial_file_base.h"


class CSerialFileComNobuf: public CSerialFileBase
{
public:
	CSerialFileComNobuf();
	~CSerialFileComNobuf();
public:
	//实现类似文件操作最基本的5个API fopen, fclose,fwrite,fread,fseek.
	virtual int Open(void * file,uint64_t fileLBA, uint32_t fileSpace, int acess_mod) ;

	virtual int Close();
	virtual int ReOpen(); //重新再打开同样一个文件

	virtual int Seek(int32_t offset,int whence);

	virtual int Read (uchar_t * pBuf, uint32_t dataSize, bool bLock = true);

	virtual int Write(uchar_t * pBuf, uint32_t dataSize, bool bLock = true);

	virtual int ReadPos(uint32_t offset, uchar_t * pBuf, uint32_t dataSize, bool bLock = true) ;

	virtual int WritePos(uint32_t offset, uchar_t * pBuf, uint32_t dataSize, bool bLock = true) ;

	virtual int FillTotalSpace();
	//主要是录像专用的接口
	int WriteCachePos(uint32_t offset, uchar_t * pBuf, uint32_t dataSize, bool bLock = true);

	virtual void Flush();
	virtual uint32_t get_cur_offset(bool bReal = false)
	{
		return m_cur_offset;
	}

protected:
	char *   m_pCacheBuf;
#ifdef _WIN32
	HANDLE   m_fd;
#else
	int      m_fd;
#endif	
	//m_baseLBA  文件的地址
};

#endif
